import Findmusic from '@/component/Findmusic.vue'
import { createRouter,createWebHashHistory } from 'vue-router'
import Mymusic from '@/component/Mymusic.vue'
import Lovemusic from '@/component/Lovemusic.vue'
import Collectmusic from '@/component/Collectmusic.vue'
import Plant1 from '@/component/Plant1.vue'
import Plant2 from '@/component/Plant2.vue'
import Plant3 from '@/component/Plant3.vue'
import _404 from '@/component/404.vue'
let router =createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:'/',
            redirect:'/findmusic'
        },
        {
            name:'Find',
            path:'/findmusic',
            redirect:'/findmusic/plant1',
            component:Findmusic,
            children:[
                {path:'/findmusic/plant1',component:Plant1},
                {path:'/findmusic/plant2',component:Plant2},
                {path:'/findmusic/plant3',component:Plant3}
            ]
        },
        {
            name:'Mymusic',
            path:'/mymusic/:fid',
            component:Mymusic
        },
        {
            path:'/lovemusic/:fid',
            component:Lovemusic
        },
        {
            path:'/collectmusic',
            component:Collectmusic
        },
        {
            path:'/:pathMatch(.*)*',
            component:_404
        },

    ]
})
let isbool=true;
router.beforeEach((to,from)=>{
    if(isbool===false&&to.path==='/collectmusic')
    {
        alert('Please log')
        return false
    }
    else{
        return true
    }

})
export default router